/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import xml.Parser;


/**
 *
 * @author gravena
 */
public class ClientHandler implements Runnable {
    private DatagramSocket conn;
    public static final int DEFAULT_PACKET_SIZE = 512; /* In bytes */

    public ClientHandler() {
        try {
            this.conn = new DatagramSocket(6023);
        } catch (SocketException ex) {
            System.out.println(ex.getMessage());
        }
    }

    public void run() {
        while(true) {
            byte b[] = new byte[DEFAULT_PACKET_SIZE];
            DatagramPacket p = new DatagramPacket(b, b.length);
            try {
                this.conn.receive(p);
            } catch (IOException ex) {
                System.out.println(ex.getMessage());
            }

            String xml = new String(b);
            System.out.println(xml);
            Parser par = new Parser(xml);
        }
    }

}
